package com.itheima.sh.user.service;

import com.itheima.sh.user.mapper.UserMapper;
import com.itheima.sh.user.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
@Slf4j
public class UserService {
    @Autowired
    private UserMapper userMapper;
    @Value("${server.port}")
    int port;
    public User queryById(String username) {
        int num = new Random().nextInt(5000);
        log.info("服务被调用 睡眠时长==>"+num);
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        User user = userMapper.findById(username);
        user.setEmail(port+"");
        return user;
    }
}